<template>
  <div class="creatins">
    <div class="box" v-for="i in list" :key="i.id">
      <div class="item" @click="userdetai(i.id)">
        <img :src="i.avatar|picUrl" alt="" />
        <div class="user">
          <span class="username">{{ i.username }}</span>
          <span class="fans"
            >{{ i.occupation }} · 粉丝{{ i.count.count_follower }}</span
          >
        </div>
        <div @click.stop="attention(i.id)" class="guanzhu" v-if="attentionList.indexOf(i.id)==-1">关注</div>
        <div @click.stop="attention(i.id)" class="guanzhu guanzhued" v-else>已关注</div>
      </div>
      <div class="videobox">
        <div class="videos" v-for="item in i.articles" :key="item.id" @click="onClick(item.id)">
          <img :src="item.cover|picUrl" alt="" />
          <span>{{ item.duration | delaytime }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {mapState} from "vuex";
export default {
  props: {
    list: Array,
  },
  methods:{
    attention(id){
      this.$store.commit('addAttention',{id:id})
    },
      onClick(id) {
        // this.$store.commit("upVideoUrl", {id:id});
        this.$router.push({ path: "/playvideoview",query:{id:id} });
    },
    userdetai(id){
      this.$router.push({path:"/userpage",query:{id:id}})
    }
  },
  computed:{
    ...mapState(["attentionList"])
  }
};
</script>

<style lang="less" scoped>
.creatins {
  .box {
    height: 160px;
    border-bottom: 1px solid #f0f0f0;
    .item {
      height: 80px;
      display: flex;
      align-items: center;
      border-bottom: 1px solid #f7f7f7;
      img {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        margin-right: 10px;
      }
      .user {
        display: flex;
        flex-direction: column;
        flex: 1;
        .username {
          font-size: 15px;
          font-weight: 600;
        }
        .fans {
          font-size: 12px;
          color: #aaa;
        }
      }
      .guanzhu {
        width: 80px;
        height: 30px;
        padding: 5px 15px;
        border-radius: 26px;
        font-weight: 500;
        text-align: center;
        color: #e76961;
        background-color: #fbeee8;
        &.guanzhued{
          background-color: #ddd;
          color: #888;
        }
      }
    }
    .videobox {
      display: flex;
      justify-content: space-between;
      .videos {
        position: relative;
        width: 31.5%;
        border-radius: 5px;
        overflow: hidden;
        img {
          width: 100%;
          height: 60px;
          display: block;
        }
        span {
          position: absolute;
          right: 5px;
          bottom: 5px;
          font-size: 12px;
          color: white;
        }
      }
    }
  }
}
</style>